package com.budwk.app.sqfw.controllers.admin.common;

import com.budwk.app.sqfw.services.common.SqfwOnlineTemplateService;
import com.budwk.app.sqfw.vo.SqfwOnlineTemplateVO;
import com.budwk.starter.common.openapi.annotation.*;
import com.budwk.starter.common.page.Pagination;
import com.budwk.starter.common.result.Result;
import com.budwk.starter.log.annotation.SLog;
import lombok.extern.slf4j.Slf4j;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.POST;
import org.nutz.mvc.annotation.Param;

/**
 * @program: community-admin
 * @description: 在线模板
 * @author: LJT
 * @create: 2024-05-31 16:45
 **/
@IocBean
@At("/platform/sqfw/onlineTemp")
@ApiDefinition(tag = "在线模板（后台管理系统）")
@Slf4j
public class SqfwOnlineTemplateForAdminController {

    @Inject
    private SqfwOnlineTemplateService sqfwOnlineTemplateService;

    /**
     * 列表查询
     */
    @At
    @Ok("json")
    @POST
    @ApiOperation(name = "列表查询")
    @ApiFormParams(
            value = {
                    @ApiFormParam(name = "pageNo", example = "1", description = "页码", type = "integer"),
                    @ApiFormParam(name = "pageSize", example = "10", description = "页大小", type = "integer"),
                    @ApiFormParam(name = "pageOrderName", example = "create_date", description = "排序字段"),
                    @ApiFormParam(name = "pageOrderBy", example = "descending", description = "排序方式")
            },
            implementation = SqfwOnlineTemplateVO.class
    )
    @ApiResponses(
            implementation = SqfwOnlineTemplateVO.class
    )
    @SLog(tag = "公共列表查询（后台管理系统）", value = "${args[0]}}")
    //@SaCheckLogin
    public Result<?> list(@Param("..") SqfwOnlineTemplateVO bean,
                          @Param("pageNo") int pageNo,
                          @Param("pageSize") int pageSize,
                          @Param("pageOrderName") String pageOrderName,
                          @Param("pageOrderBy") String pageOrderBy) {
        Pagination pagination = sqfwOnlineTemplateService.list(bean);
/*        Map<String, String> map = new HashMap<String, String>();
        map.put("excelData", pagination.getList(Sqfw_datamange_community.class));*/
        return Result.data(pagination);
    }

    @At
    @Ok("json")
    @POST
    @ApiOperation(name = "添加数据")
    @ApiFormParams(
            implementation = SqfwOnlineTemplateVO.class
    )
    @SLog(tag = "添加数据", value = "${args[0]}")
    //@SaCheckLogin
    public Result<?> save(@Param("..") SqfwOnlineTemplateVO bean) {
        sqfwOnlineTemplateService.save(bean);
        return Result.success();
    }
}
